<template>
        <div id="screen">
            
            <div id="screen-content" v-if="FilterShopping[0]">
                <!--等级  -->
                <div class="content">
                    <h4>{{FilterShopping[0].filterTitle}}</h4>
                    <ul>
                        <li v-for="(f,i) in FilterShopping[0].filterContent" :key="i" @click="classClick(f)" :class="{'heigh-light':goodsClass==f}">{{f}}</li>
                    </ul>
                </div>
                <!--用途  -->
                <div class="content">
                    <h4>{{FilterShopping[1].filterTitle}}</h4>
                    <ul>
                        <li v-for="(f,i) in FilterShopping[1].filterContent" :key="i" @click="useClick(f)" :class="{'heigh-light':use==f}">{{f}}</li>
                    </ul>
                </div>
                <!-- 采摘季节 -->
                <div class="content">
                    <h4>{{FilterShopping[2].filterTitle}}</h4>
                    <ul>
                        <li v-for="(f,i) in FilterShopping[2].filterContent" :key="i" @click="seasonClick(f)" :class="{'heigh-light':season==f}">{{f}}</li>
                    </ul>
                </div>
                <!-- 年份 -->
                <div class="content">
                    <h4>{{FilterShopping[3].filterTitle}}</h4>
                    <ul>
                        <li v-for="(f,i) in FilterShopping[3].filterContent" :key="i" @click="yearClick(f)" :class="{'heigh-light':year==f}">{{f}}</li>
                    </ul>
                </div>
                <!--净含量  -->
                <div class="content">
                    <h4>{{FilterShopping[4].filterTitle}}</h4>
                    <ul>
                        <li v-for="(f,i) in FilterShopping[4].filterContent" :key="i" @click="netContentClick(f.name,f.value.min,f.value.max)" :class="{'heigh-light':netContent==f.name}">{{f.name}}</li>
                    </ul>
                </div>
            </div>
             <div id="screen-commit-box">
                <div @click="resetClick">重置</div>
                <div @click="commitClick">确定</div>
            </div> 
            
        </div>
</template>
<script>
import {mapState} from "vuex";
export default {
    mounted(){
        this.$store.dispatch("requestFilter");
    },
    computed:{
        ...mapState([
            "FilterShopping"
        ]),
    },
    data(){
        return {
            goodsClass:"全部",
            use:"全部",
            season:"全部",
            year:"全部",
            netContent:"全部",
            screen:{
                goodsClass:"",
                use:"",
                season:"",
                year:null,
                netContent:{min:null,max:null}

            },
        }
    },
    methods:{
        classClick(f){
            this.goodsClass = f;
            if(f=="全部"){
                this.screen.goodsClass = "";
            }else{
                this.screen.goodsClass = f;
            }
        },
        useClick(f){
            this.use = f;
            if(f=="全部"){
                this.screen.use = "";
            }else{
                this.screen.use = f;
            }
        },
        seasonClick(f){
            this.season = f;
            if(f=="全部"){
                this.screen.season = "";
            }else{
                this.screen.season = f;
            }
        },
        yearClick(f){
            this.year = f;
            if(f=="全部"){
                this.screen.year = "";
            }else{
                this.screen.year = f;
            }
        },
        netContentClick(f,n,x){
            this.netContent = f;
            this.screen.netContent.min = n;
            this.screen.netContent.max = x;
        },
        commitClick(){
            var data ={
            classifyName:this.$route.params.classifyName,
            teaName:this.$route.params.tea,
            screen:this.screen
        }
            this.$store.dispatch("requestGoodsList",data);
            this.$store.commit("setAniShow",false);
        },
        resetClick(){
            this.goodsClass="全部",
            this.use="全部",
            this.season="全部",
            this.year="全部",
            this.netContent="全部",
            this.screen={
                goodsClass:"",
                use:"",
                season:"",
                year:null,
                netContent:{min:null,max:null}

            }
        }
    }
}
</script>
<style scoped>
    #screen{
        position: absolute;
        width: 100%;
        height: 50vh;
        left: 0;
        bottom: 0;
        z-index: 100;
        
        
    }
    #screen-content{
        width: 100%;
        height: calc(50vh - 12.2vw);
        overflow-y: scroll;
        background-color: white;
    }
    #screen-commit-box{
        width: 100%;
        height: 12.2vw;
         background-color: white; 
        border-top: 1px #f4f4f4 solid;
        color: #FF3600;
        display: flex;
        text-align: center;
        line-height: 12.2vw;

    }
    #screen-commit-box div:nth-of-type(1){
        width: 50%;
    }
    #screen-commit-box div:nth-of-type(2){
        width: 50%;
        background-color: #FF3600;
        color: white;
    }
    .content{
        padding: 2.8vw;
    }
    h4{
        
    }
    ul{
        margin: 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        text-align: center;
        justify-content: space-between
    }
    li{
        list-style: none;
        width: 28%;
        padding: 1.4vw;
        border:#f4f4f4 solid 1px;
        margin: 1.5vw  0;
    }
    .heigh-light{
        border:#ff3600 solid 1px;
    }
</style>